<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<div class="span9">
	<div class="well well-large">
		
		<c:if test="${not empty errors}">
			<c:forEach items="${errors}" var="error">
				<div class="alert alert-error">
					<button type="button" class="close" data-dismiss="alert">&times;</button>
					${error.message}
				</div>
			</c:forEach>
		</c:if>
		
   		<c:choose>
   			<c:when test="${empty convenioList}">
   			    <div class="alert alert-info">
			    	<button name="skipAjax" type="button" class="close" data-dismiss="alert">&times;</button>
			    	<h3><fmt:message key="BUNDLE_WARNING"/></h3> <fmt:message key="BUNDLE_EMPTY_CONVENIOS"/>
			    </div>
   			</c:when>
   			<c:otherwise>
   				<table class="table table-bordered table-hover">
	   				<caption><h3> <fmt:message key="BUNDLE_CONVENIOS"/> </h3></caption>
	   				<thead>
		   				<tr>
							<th><fmt:message key="BUNDLE_NUMERO"/></th>
							<th><fmt:message key="BUNDLE_NOME"/></th>
							<th><fmt:message key="BUNDLE_ACTIONS"/></th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${convenioList}" var="convenio">
							<tr>
								<td>${convenio.numero}</td>
								<td>${convenio.nome}</td>
								<td>
									<a class="btn btn-small btn-primary" href="${pageContext.request.contextPath}/convenios/${convenio.id}/edit">
										<i class="icon-edit icon-white"></i> <fmt:message key="BUNDLE_EDIT"/>
									</a>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
   			</c:otherwise>
   		</c:choose>
	</div>
</div>

<div class="span3">
    <a class="btn btn-inverse" href="${pageContext.request.contextPath}/convenios/new">
    	<i class="icon-list-alt icon-white"></i> <fmt:message key="BUNDLE_NEW_CONVENIO"/>
    </a>
    
	<table class="table table-bordered">
	   	<caption><i class="icon-th-list"></i> <fmt:message key="BUNDLE_LAST_CONVENIOS"/></caption>
	    <thead>
			<tr>
		    	<th><fmt:message key="BUNDLE_NUMERO"/></th>
		    	<th><fmt:message key="BUNDLE_NOME"/></th>
		    </tr>
		</thead>
		<tbody>
			<c:if test="${empty lastConvenioList}">
				<tr>
					<td colspan="4">
						<div class="alert alert-info">
					    	<button name="skipAjax" type="button" class="close" data-dismiss="alert">&times;</button>
					    	<i class="icon-ban-circle"></i> 
					    </div>
				    </td>
			    </tr>
			</c:if>
			<c:forEach items="${lastConvenioList}" var="ultimoConvenio">
	   	    	<tr class="success">
					<td>${ultimoConvenio.numero}</td>
					<td>${ultimoConvenio.nome}</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>